#!/bin/bash

rm -rf ../client/src/api
mkdir ../client/src/api

docker run --rm \
    --user "$(id -u):$(id -g)" \
    -v "${PWD}/../client/src/api:/local/out" \
    -v "${PWD}/../OpenApi.yml:/local/in.yaml" \
    openapitools/openapi-generator-cli generate \
        -i /local/in.yaml \
        -g typescript-axios \
        -o /local/out \
        --additional-properties=enumPropertyNaming=original,modelPropertyNaming=original

# Remove not needed git_push.sh
rm -f ../client/src/api/git_push.sh

# Fix lint errors
docker run --rm -it \
    --user "$(id -u):$(id -g)" \
    -v "${PWD}/../client:/app" \
    --entrypoint="npm" \
    --workdir="/app" \
    node:20-bookworm-slim run lint -- --fix src/api
